package spring.JUNIT.aop.AspectJ;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class zzyAspect {

	@Pointcut("execution(* JUNIT.aop.AspectJ.biz.*Biz.*(..))")
	public void pointcut() {

	}

	@Pointcut("within(JUNIT.aop.AspectJ.biz.*)")
	public void bizPointcut() {

	}

	@Before("pointcut()")
	public void before() {
		System.out.println("before");
	}

	@AfterReturning(pointcut = "pointcut()", returning = "retValue")
	public void doAccessCheck(Object retValue) {
		System.out.println("这是返回值" + retValue);
	}

	@AfterThrowing(pointcut = "pointcut()", throwing = "e")
	public void afterThrowing(Throwable e) {
		System.out.println("报错啦" + e);
	}

	@After(value = "pointcut()")
	public void after() {
		System.out.println("after啦");
	}

	@Around("pointcut()")
	public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable {

		System.out.println("around1");
		Object retValObject = pjp.proceed();// 真正执行方法
		System.out.println("around2" + retValObject);
		return retValObject;
	}

	@Before("pointcut() && @annotation(zzy)")
	public void befroeParam(zzy zzy1) {

	}
}
